/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.ianaz.session;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.ianaz.bean.Documento;

/**
 *
 * @author rainolsi
 */
@Stateless
public class DocumentoFacade implements DocumentoFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(Documento documento) {
        em.persist(documento);
    }

    public void edit(Documento documento) {
        em.merge(documento);
    }

    public void remove(Documento documento) {
        em.remove(em.merge(documento));
    }

    public Documento find(Object id) {
        return em.find(Documento.class, id);
    }

    public List<Documento> findAll() {
        return em.createQuery("select object(o) from Documento as o").getResultList();
    }

}
